package com.banggood.pss.mqtools.util;

import com.rabbitmq.client.ConnectionFactory;

/**
 * @author Mr.chen
 * @date 2020/8/14 14:56
 */
public class ConnectionUtil {

    /**
     * 获取MQ的连接
     * @return MQ连接资源
     */
    public static ConnectionFactory getConnectionFactory(String host, int port, String virtualHost, String userName, String password) {
        //定义一个连接工厂
        ConnectionFactory factory = new ConnectionFactory();

        //设置服务器地址
        factory.setHost(host);
        // AMQP 端口
        factory.setPort(port);
        //vhost
        factory.setVirtualHost(virtualHost);
        //用户名
        factory.setUsername(userName);
        //密码
        factory.setPassword(password);

        return factory;
    }



}
